﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.Practices.Unity;
using SuperJ.CMS.Interfaces.Repositories;
using SuperJ.CMS.Interfaces.Services;
using SuperJ.CMS.Repositories;
using SuperJ.CMS.Services;
using SuperJ.CMS.Models;
namespace SuperJ.CMS.Unity
{
    public class ConfigUnity
    {
        public void Initialise()
        {
            IUnityContainer c = GetUnityContainer();
            //var orderRepository = c.Resolve<IAdminMenuService>();
            DependencyResolver.SetResolver(new UnityDependencyResolver(c));
        }
        private IUnityContainer GetUnityContainer()
        {
            var container = new UnityContainer();
            //注册
            //container.RegisterType<IAdminMenuRepository<AdminMenuRoot>, AdminMenuRepository>();
            container.RegisterType<IAdminMenuService, AdminMenuService>();
            container.RegisterType<IAdminMenuRepository, AdminMenuRepository>();
            //使用
            //var customerRepository = container.Resolve<IAdminMenuRepository<AdminMenuRoot>>();
            container.RegisterType<IAnnounceRepository<SuperJ_Announce>, AnnounceRepository>();
            container.RegisterType<IAnnounceService, AnnounceService>();
            
            return container;
        }
    }
}
